package io;

import model.Player;
import pack.Engine;

public final class LoginProtocol {
    public static void login(Player p) {
        int connectingVersion = p.in().getInt();
        String username = p.in().getString();
        String password = p.in().getString();
        p.setUsername(username);
        p.setPassword(password);
        p.setId(p.world().getFreePlayerId());
        p.out().addByte(2);
        p.out().addShort(p.id());
        p.setIsVisible(true);
        p.setCoords(Engine.SPAWN_X, Engine.SPAWN_Y);
        p.setAppearance(Engine.DEFAULT_HEAD_ID, Engine.DEFAULT_TORSO_ID, Engine.DEFAULT_LEGS_ID);
    }
}